home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////////////////////
- // fracsub2.cpp
- // This file is an extension of CIterationsview and 'fracsub1.cpp'
- // Class Function implementations
- //
- //
-
- #include "stdafx.h"
- #include "itriazon.h"
- #include "itriadoc.h"
- #include "itriavw.h"
- #include "external.h"
- #include "math.h"
-
- ////////////////////////////////////////////////////
- void CIterationsView::Pattern5_Case07()
- {
- }
-
- void CIterationsView::Pattern5_Case08()
- {
- /////////////////////////////////////////////////////////
- // Roger T. Stevens Methods
- // Legendre Polynomial Fractal
-
- P = cx; // Column
- Q = cy; // Row (Backwards ?)
-
- for (i = 0; (i < NMAX) && ((xsquared + ysquared) < dBailout) ; i++)
- {
- temp = 0.5*(5.0*x*x*x - 15.0*x*y*y - 3.0*x) + P;
- y = 0.5*(15.0*x*x*y - 5.0*y*y*y) + Q;
- x = temp;
- xsquared = x*x;
- ysquared = y*y;
- if (nFilter) Delta_z((double)x, (double)y);
- }
- if (nFilter) Filter_Complete();
-
- if (i >= NMAX)
- b_MAX = TRUE;
- else
- b_MAX = FALSE;
-
- i %= NMAX-1;
- i = abs(i);
- if (i < 0 || i > NMAX)
- {
- AfxMessageBox("1: error, i out of range");
- Row = 0;
- }
- }
-
- void CIterationsView::Pattern5_Case10()
- {
- /////////////////////////////////////////////////////////
- // Roger T. Stevens Methods
- // 3rd Order Newton
-
- x = cx;
- y = cy;
-
- old_x = old_y = 42;
- for (i=0 ; i<NMAX ; i++)
- {
- sqdif = (x - y) * (x + y);
- xsquared = x*x;
- ysquared = y*y;
- denom = 3.0 * (sqdif*sqdif + 4.0*xsquared*ysquared);
- if (denom == 0)
- denom = 1E-10;
- y = 0.6666667*y - 2.0*x*y/denom;
- x = 0.6666667*x + sqdif/denom;
- if (fabsl(old_x - x) < 1E-10 && (fabsl(old_y - y) < 1E-10))
- break;
- old_x = x;
- old_y = y;
- if (nFilter) Delta_z((double)x, (double)y);
- }
- if (nFilter) Filter_Complete();
-
- //char cstr[81];
- //wsprintf(cstr,"i=%d",i);
- //GetParent()->SetWindowText(cstr);
-
- if (i >= NMAX)
- b_MAX = TRUE;
- else
- b_MAX = FALSE;
-
- i %= NMAX-1;
- i = abs(i);
- if (i < 0 || i > NMAX)
- {
- AfxMessageBox("2: error, i out of range");
- Row = 0;
- }
- }
-
- void CIterationsView::Pattern5_Case11()
- {
- /////////////////////////////////////////////////////////
- // Roger T. Stevens Methods
- // 7nth Order Newton
-
- x = cx;
- y = cy;
-
- old_x = old_y = 42;
- for (i=0 ; i<NMAX ; i++)
- {
- xsquared = x*x;
- ysquared = y*y;
- sqsum = xsquared + ysquared;
- denom = 7.0 * (sqsum*sqsum*sqsum*sqsum*sqsum*sqsum);
- if ((denom > -.00004) && (denom < .00004))
- denom = .00004;
- ytemp = 0.85714285*y - (6.0*x*x*x*x*x*y -
- 20.0*x*x*x*y*y*y + 6.0*x*y*y*y*y*y)/denom;
- x = 0.85714285*x + (x*x*x*x*x*x -
- 15.0*x*x*x*x*y*y +
- 15.0*x*x*y*y*y*y -
- y*y*y*y*y*y)/denom;
- y = ytemp;
- if (fabsl(old_x - x) < 1E-10 && (fabsl(old_y - y) < 1E-10))
- break;
- old_x = x;
- old_y = y;
- if (nFilter) Delta_z((double)x, (double)y);
- }
- if (nFilter) Filter_Complete();
-
- //char cstr[81];
- //wsprintf(cstr,"i=%d",i);
- //GetParent()->SetWindowText(cstr);
-
- if (i >= NMAX)
- b_MAX = TRUE;
- else
- b_MAX = FALSE;
-
- i %= NMAX-1;
- i = abs(i);
- if (i < 0 || i > NMAX)
- {
- AfxMessageBox("3: error, i out of range");
- Row = 0;
- }
- }
-
- void CIterationsView::Pattern5_Case06()
- {
- }
-
- void CIterationsView::Pattern5_Case12()
- {
- }
-
- void CIterationsView::Pattern5_Case13()
- {
- }
-
- void CIterationsView::Pattern5_Case14()
- {
- }
-
- void CIterationsView::Pattern5_Case15()
- {
- // Roger T. Stevens method for the Tchebychev C5 Fractal
-
- x = P = cx; // Column
- y = Q = cy; // Row (Backwards ?)
- old_x = old_y = 0;
-
- for (i = 0; (i < NMAX) && ((xsquared + ysquared) < dBailout) ; i++)
- {
- temp_x = x*x*x*x*x -
- 10.0*x*x*x*y*y +
- 5.0*x*y*y*y*y -
- 5.0*x*x*x +
- 15.0*x*y*y +
- 5.0*x;
-
- temp_y = 5.0*x*x*x*x*y -
- 10.0*x*x*y*y*y +
- y*y*y*y*y -
- 15.0*x*x*y +
- 5.0*y*y*y +
- 5.0*y;
- x = P*temp_x - Q*temp_y;
- y = Q*temp_x + P*temp_y;
-
- xsquared = x*x;
- ysquared = y*y;
- if (nFilter) Delta_z((double)x, (double)y);
- }
- if (nFilter) Filter_Complete();
-
- if (i >= NMAX)
- b_MAX = TRUE;
- else
- b_MAX = FALSE;
-
- i %= NMAX-1;
- i = abs(i);
- if (i < 0 || i > NMAX)
- {
- AfxMessageBox("4: error, i out of range");
- Row = 0;
- }
- }
-
- // Color map the iteration data
- void CIterationsView::Pattern5_Case17()
- {
- if (idata == NULL)
- {
- delete idata;
-
- // create a data array for the rows
- // AfxMessageBox("Creating New iter data array");
- idata = new short [dim.cx];
- }
-
- if (px == 0)
- {
- // AfxMessageBox("Reading a new row");
- // Read a row from the iteration data file
- TRY
- {
- itrData.Read(idata, dim.cx*2);
- }
- CATCH( CFileException, e )
- {
- itrData.Close();
- AfxMessageBox( "Error reading from file: itrdata.itr");
- }
- END_CATCH
- }
-
- if (px >= dim.cx || px < 0)
- AfxMessageBox("Error: 'px' is out of range");
-
- // transfer the data one data point at a time
- i = (int) idata[px];
-
- //char cstr1[81];
- //wsprintf(cstr1, "i=%X", i);
- //if (AfxMessageBox(cstr1, IDOK || IDCANCEL) == IDCANCEL)
- // return;
-
- if (i < 0 || i > NMAX)
- {
- //AfxMessageBox("Error, iteration data is out of range");
- //char cstr[81];
- //wsprintf(cstr,"Error: px=%d,idata=%d",px, i);
- //AfxMessageBox(cstr);
- i = 0;
- //GetParent()->SetWindowText(cstr);
- }
- }
-
- // Color map the iteration data
- //void CIterationsView::Pattern5_Case18()
- //{
- // // AfxMessageBox("Case 18");
- //
- // pITR = (LPSTR) ::GlobalLock((HGLOBAL) hITR_DATA);
- //
- // itr_data = (short int huge *) pITR + 4;
- //
- // i = itr_data[(DWORD) (((DWORD) (dim.cy - 1 - py)
- // * (DWORD) dim.cx) + (DWORD) px)];
- //
- // if (i < 0 || i > NMAX)
- // {
- // //AfxMessageBox("Error, iteration data is out of range");
- // char cstr[81];
- // wsprintf(cstr,"Error: px=%d,idata=%d",px, i);
- // //AfxMessageBox(cstr);
- // i = 0;
- // GetParent()->SetWindowText(cstr);
- // }
- //
- // ::GlobalUnlock((HGLOBAL) hITR_DATA);
- //}
-
-